<template>
  <div id="main2"></div>
</template>

<script>
import * as echarts from 'echarts';

export default {
  props:["data"],
  data() {
    return {}
  },
  methods:{
    initEchart(data,labels){
      const chartDom = document.getElementById('main2')
      const myChart = echarts.init(chartDom)
      let option
      option = {
        tooltip: {
          trigger: 'axis'
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        color:"#108af1",
        xAxis: {
          type: 'category',
          // boundaryGap: false,
          data: labels
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name:'好评率',
            type: 'line',
            stack: 'Total',
            data: data
          }
        ]
      };
      option && myChart.setOption(option);
    },
  },
  watch:{
    data({data,labels}){
      this.initEchart(data,labels)
    }
  },
  mounted() {
  }
}
</script>

<style scoped>
#main2 {
  width: 100%;
  height: 350px;
}
</style>
